class AlertHelper {

    constructor() {
        if(!Swal) {
            console.log("未导入sweetalert2.js插件, 不能使用该辅助类");
        } else {
            this.toast = Swal.mixin({
                toast: true,
                position: 'top-end',
                showConfirmButton: false,
                timer: 3000
            });
        }
    }

    success(message) {
        this.alertMessage("success", message);
    }

    error(message) {
        this.alertMessage("error", message);
    }

    warning(message) {
        this.alertMessage("warning", message);
    }

    info(message) {
        this.alertMessage("info", message);
    }

    question(message) {
        this.alertMessage("question", message);
    }

    alertMessage(type, message) {
        this.toast.fire({
            //type可选值: success, error, warning, info, question.
            type: type,
            title: message
        })
    }

}